﻿<!DOCTYPE html>
<!--[if lt IE 7]>    <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="zh-cn" > <![endif]-->
<!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8" lang="zh-cn" > <![endif]-->
<!--[if IE 8]>    <html class="no-js lt-ie9" lang="zh-cn" ><![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="zh-cn">
<!--<![endif]-->
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>野兽派--荒野之花真丝斜纹丝巾</title>
    <meta name="keywords" content="荒野之花真丝斜纹丝巾" />
    <meta name="description" content="" />
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1.0, user-scalable=no"> 
    <!-- 加载js/css -->
    <link type="text/css" rel="stylesheet" href="/shop/templates/yeshou/cssfont-awesome.min.css?v=3">
    <link type="text/css" rel="stylesheet" href="/shop/templates/yeshou/csswapmain.css?v=5">
    <script type="text/javascript" src="/shop/templates/yeshou/jszepto.min.js?v=3"></script>
    <script>
        var _hmt = _hmt || [];
        (function () {
            var hm = document.createElement("script");
            hm.src = "//hm.baidu.com/hm.js?7c10355ee0f6b21af208947325fd4ad7";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
        })();
    </script>
</head>
<body>
    <div id="J_Wrappear">
        <div class="lay-wrap J_MenuBody" id="J_MenuSwipe"> 
            <!--顶部-->
            <vt:template id="header" file="_header.html" charset="utf-8" />
            <!--end顶部-->
            <script>
                $(document).ready(function () {
                    initCart();
                });

                /**重新加载购物车数量和总价**/
                function initCart() {
                    $.ajax({
                        url: '/wap/cart/initCart.htm',
                        dataType: 'json',
                        async: false,
                        success: function (data) {
                            if (data.success) {
                                var num = data.retObj.cart_count;
                                var cart_a_link = $("<a href=\"/wap/cart/list.htm\"></a>");
                                if (num != 'undefined' && parseFloat(num) > 0) {
                                    $('#J_toPay').removeAttr("disabled");
                                    $('#J_toPay').removeClass('u-disabled');
                                    cart_a_link.append($("<i class=\"shop-num\">" + num + "</i>"));
                                } else {
                                    //购物车列表页 
                                    $('#J_totalPrice').empty();
                                    $('#J_toPay').attr('disabled', "true");
                                    $('#J_toPay').addClass('u-disabled');
                                    $('#J_cart_list').empty();
                                    $('#J_cart_list').append($('<p id="J_cart_empty" class="empty">您的购物车是空的</p>'));
                                }
                                $(".m-shop-cart").empty();
                                $(".m-shop-cart").append(cart_a_link);
                                var price = data.retObj.total_price;
                                if (price != 'undefined' && parseFloat(price) > 0) {
                                    $('#J_totalPrice').html('总计：￥' + price);
                                }
                            }
                        }
                    });
                }
            </script>

            <div class="lay-til J_MenuBody" id="J_SubHead">
                <div class="header-con">
                    <i class="arrow-back" onclick="history.go(-1)">
                        <img src="/wap/images/pay_03.png" alt="" /></i>
                    <h1>商品详情</h1>
                </div>
            </div>
            <div class="lay-body lay-body2" id="J_MainBody">
                <div class="list">
                    <!--产品详情-->
                    <div class="swiper-container">
                        <div class="swiper-wrapper">
                            <div class="swiper-slide">
                                <img src="http://oss.thebeastshop.com/website/13034231_i.jpg"></div>
                        </div>
                        <div class="pagination"></div>
                    </div>
                    <div class="detail-head">
                        <h1>THE BEAST</h1>
                        <h2>荒野之花真丝斜纹丝巾</h2>
                        <h3>The Desert Silk Scarves</h3>
                    </div>
                    <div class="detail-price clearfix">
                        <p class="fl" id="itemPriceFl">
                            ￥ 
			   		790.0 
			      <!--  <span class="u-freight">免运费</span>-->
                        </p>
                        <!-- <div class="fr J_Collect"><i class="icon-heart-empty"></i> 加入收藏</div> -->
                    </div> 
                    <input type="hidden" value="" name="selSubItem" id="selSubItem">  
                    <div class="m-detail-info">
                        <div class="info-til J_DetailToggle">
                            <h3>简短介绍 <span>DETAILS</span></h3> 
                            <i class="minus-sign"></i> 
                        </div> 
                        <div class="info-container J_Node">
                            <p>
                                <p>尺寸：110*110cm<br />
                                    面料：100%桑蚕丝<br />
                                    产地：中国</p>
                            </p>
                        </div> 
                    </div>  
                    <!--页脚产品推荐--> 

                </div>
                <footer class="lay-foot J_MenuBody">
                    <p class="fl" id="footPriceFl">
                        ￥  790.0 
                    </p> 
                    <button class="foot-btn" id="Baidu_AddCart" onclick="_hmt.push(['_trackEvent', 'wap_addCart', 'click']);">加入购物车</button> 
                </footer>
            </div>
        </div>
        <div class="m-mask J_MenuBody" id="J_Mask"></div> 
        <!--左边菜单-->
        <vt:template id="_bottom" file="_bottom.html" charset="utf-8" />
        <!--end左边菜单-->
        <script type="text/javascript" src="/shop/templates/yeshou/jsmain.js?v=1"></script>
        <script type="text/javascript" src="/shop/templates/yeshou/jsidangerous.swiper.min.js"></script>
        <script>
            function serchItems() {
                var skeywordVal = document.getElementById('skeyword').value;
                if (skeywordVal != '') {
                    window.location.href = "/wap/item/search.htm?searchKeyword=" + skeywordVal;
                } else {
                    alert('请输入搜索词');
                }
            }

            $("#skeyword").keydown(function (event) {
                if (event.keyCode == 13) {
                    serchItems();
                }
            });
        </script>



        <!-- Piwik -->
        <script type="text/javascript">
            var _paq = _paq || [];
            _paq.push(['trackPageView']);
            _paq.push(['enableLinkTracking']);
            (function () {
                var u = "//www.thebeastshop.com/piwik/";
                _paq.push(['setTrackerUrl', u + 'piwik.php']);
                _paq.push(['setSiteId', 1]);
                var userID = '475008', userName = '王大明';
                userID != '' && _paq.push(['setCustomVariable', 1, 'userID', userID, 'visit']);
                userName != '' && _paq.push(['setCustomVariable', 2, 'userName', userName, 'visit']);
                _paq.push(['trackPageView']);
                var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
                g.type = 'text/javascript'; g.async = true; g.defer = true; g.src = u + 'piwik.js'; s.parentNode.insertBefore(g, s);
            })();
        </script>
        <noscript>
            <p>
                <img src="//www.thebeastshop.com/piwik/piwik.php?idsite=1" style="border: 0;" alt="" /></p>
        </noscript>
        <!-- End Piwik Code -->
    </div>
    <script type="text/javascript">
        /*banner轮播*/
        var mySwiper = new Swiper('.swiper-container', {
            pagination: '.pagination',
            loop: false,
            grabCursor: true,
            paginationClickable: true
        });
        $('.pagination').eq(0).css({ marginLeft: -$('.pagination').width() / 2 + 'px' });
        $('.swiper-container').on('swipeLeft', function (e) { e.stopPropagation(); });
        $('.swiper-container').on('swipeRight', function (e) { e.stopPropagation(); });

        $('.swiper-container img').each(function () {
            var src = $(this).attr('src');
            $(this).on('tap', function (e) {
                e.preventDefault();
                var img = new Image();
                img.src = src, img.className = 'pro-detail-pic J_Pic';
                $('body').append(img);
                $('.J_Mask').show().css({ opacity: 0.5, height: $('.lay-wrap').height() + 'px' });

                $('.J_Pic').on('tap', function () {
                    $('.J_Mask').hide();
                    $(this).remove();
                });
            });
        });

        /*脚部切换产品*/
        (function () {
            function Switch(ele) {
                this.ele = ele;
                this.init();
            }
            Switch.prototype = {
                init: function () {
                    var that = this,
                            ul = this.ele.find('ul').eq(0),
                            li = this.ele.find('li'),
                            screenWidth = $('body').width() - 20;
                    li.width(screenWidth / 3);
                    ul.width(screenWidth / 3 * li.length);
                    this.ele.on('swipeLeft', function () {
                        var ul = that.ele.find('ul').eq(0), li = that.ele.find('li');
                        that.left(li, ul, screenWidth);
                    });
                    this.ele.on('swipeRight', function () {
                        var ul = that.ele.find('ul').eq(0), li = that.ele.find('li');
                        that.right(li, ul, screenWidth);
                    });
                },
                left: function (li, ul, screenWidth) {
                    li.eq(0).animate({ marginLeft: -screenWidth / 3 + 'px' }, 400, '', function () {
                        ul.append(li.eq(0)), li.eq(0).css({ marginLeft: 0 });
                    });
                },
                right: function (li, ul, screenWidth) {
                    li.eq(li.length - 1).css({ marginLeft: -screenWidth / 3 + 'px' }), ul.prepend(li.eq(li.length - 1));
                    li.eq(li.length - 1).animate({ marginLeft: 0 }, 400);
                }
            };

            $.fn.switch = function (opt) {
                opt = $.extend({}, opt);
                this.each(function () {
                    console.log($(this));
                    return new Switch($(this));
                });
            }
        })();

        $('.J_Switch').switch();

        /**信息显示/隐藏**/
        $('.J_DetailToggle').on('tap', function () {
            if ($(this).siblings('.J_Node').eq(0).css('display') == 'none') {
                $(this).find('i').eq(0).removeClass('plus-sign').addClass('minus-sign');
                $(this).siblings('.J_Node').eq(0).css({ display: 'block' });
            } else {
                $(this).find('i').eq(0).addClass('plus-sign').removeClass('minus-sign');
                $(this).siblings('.J_Node').eq(0).css({ display: 'none' });
            }
        });

        /**选择款型**/
        $('#J_Type li').on('click', function () {
            $(this).addClass('detail-type-active').siblings().removeClass('detail-type-active');
            $('#selSubItem').val($(this).attr("subitem"));


            var itemvipprice = $(this).attr("vipprice");
            var itemnormalprice = $(this).attr("normalprice");
            if (itemvipprice > 0) {
                $("#itemPriceFl").html("<p class=\"fl\">￥ " + itemvipprice + " <em class=\"u-cost-price\">" + itemnormalprice + "</em></p>");
                $("#footPriceFl").html("<p class=\"fl\">￥ " + itemvipprice + " <em class=\"u-cost-price\">" + itemnormalprice + "</em></p>");
            } else {
                $("#itemPriceFl").html("<p class=\"fl\">￥ " + itemnormalprice + "</p>");
                $("#footPriceFl").html("<p class=\"fl\">￥ " + itemnormalprice + "</p>");
            }

        });

        /*加入收藏*/
        $('.J_Collect').on('tap', function () {
            var $this = $(this);
            $.ajax({
                url: '',
                data: '',
                success: function () {
                    $this.find('i').eq(0).addClass('icon-heart').removeClass('icon-heart-empty');
                }
            });
        });

        /**加入购物车**/
        $('.foot-btn').on('click', function () {
            var hasSubItem = '';
            var selSubItem = '';
            var itemId = '8242';
            var skuId = '13034231';
            if (hasSubItem == '1') {//有子商品
                selSubItem = $("#selSubItem").val();
                if (selSubItem == '') {
                    alert('请选择');
                    return;
                } else {//如果有子商品。获取子商品的类型格式为itemid:skuid
                    var itemid_skuid = selSubItem.split(":");
                    if (itemid_skuid.length == 2) {
                        itemId = itemid_skuid[0];
                        skuId = itemid_skuid[1];
                    }
                }
            }

            if (document.getElementById('canaddcart')) {
                var canaddcart = $("#canaddcart").val();
                //alert(canaddcart);
                if (canaddcart == "notsupport") {
                    alert('您选择的区域暂时缺货');
                    return;
                }
                if (canaddcart == "false") {
                    alert("请先选择送达省市区，确认是否可以配送");
                    return;
                }
            }

            $.ajax({
                url: '/wap/cart/add.htm',
                dataType: 'json',
                data: { 'skuId': skuId, 'itemId': itemId },
                success: function (data) {
                    if (data.success == false) {
                        alert(data.message);
                    } else {
                        initCart();
                        alert('成功加入购物车');
                    }
                }
            });
        });

        $("#province_id").change(function () {
            var selectProId = $('#province_id').val();
            $("#city_id").html("");
            $("#area_id").html("");
            $("#addr-ps-id").hide();
            $("#canaddcart").val("false");

            var pickScope = $("#pickScope").val();

            if (selectProId != "") {
                $.ajax({
                    type: "post",
                    async: false, //默认为true 异步
                    url: '/pcs/city.htm?proviceOeId=' + selectProId + '&pickScope=' + pickScope,
                    dataType: 'json',
                    success: function (jsonData) {    //回传函数实体，参数为XMLhttpRequest.responseText
                        if (jsonData.success) {
                            $("#city_id").append("<option value=''>市</option>");
                            $(jsonData.retObj).each(function () {
                                $("#city_id").append("<option value='" + this['oeId'] + ":" + this['name'] + "'>" + this['name'] + "</option>");
                            });
                        } else {
                            //错误信息提示
                        }
                    },
                    error: function () {
                        //alert('加载菜单数据失败!');
                    }
                });
            }
        });

        $("#city_id").change(function () {
            var selectCityId = $('#city_id').val();
            $("#area_id").html("");
            $("#addr-ps-id").hide();
            $("#canaddcart").val("false"); 
            var pickScope = $("#pickScope").val(); 
            if (selectCityId != "") {
                $.ajax({
                    type: "post",
                    async: false, //默认为true 异步
                    url: '/pcs/district.htm?cityOeId=' + selectCityId + '&pickScope=' + pickScope,
                    dataType: 'json',
                    success: function (jsonData) {    //回传函数实体，参数为XMLhttpRequest.responseText
                        if (jsonData.success) {
                            $("#area_id").append("<option value=''>区</option>");
                            $(jsonData.retObj).each(function () {
                                $("#area_id").append("<option value='" + this['id'] + "'>" + this['name'] + "</option>");
                            });
                        } else {
                            //错误信息提示
                        }
                    },
                    error: function () {
                        //alert('加载菜单数据失败!');
                    }
                });
            }
        });

        $("#area_id").change(function () {
            $("#addr-ps-id").hide();
            var selectDistrictId = $('#area_id').val();
            var pickScope = $("#pickScope").val();
            $("#canaddcart").val("false");

            $.ajax({
                type: "post",
                async: false,
                url: '/pcs/districtCanPost.htm?districtId=' + selectDistrictId,
                dataType: 'json',
                success: function (jsonData) {    //回传函数实体，参数为XMLhttpRequest.responseText
                    if (jsonData.success) {
                        var flowerDeliveryType = jsonData.retObj.flowerDevType;
                        //alert(flowerDeliveryType + "  " + pickScope);
                        if (flowerDeliveryType == 1) {//地区支持8小时
                            if (pickScope == 'FEDEX24') {
                                $("#canaddcart").val("true");
                                $("#addr-ps-id").fadeIn();
                            }
                            if (pickScope == 'SELF') {
                                $("#canaddcart").val("true");
                                $("#addr-ps-id").fadeIn();
                            }
                        } else if (flowerDeliveryType == 2) {//地区支持24小时
                            if (pickScope == 'FEDEX24') {
                                $("#canaddcart").val("true");
                                $("#addr-ps-id").fadeIn();
                            }
                            if (pickScope == 'SELF') {
                                $("#canaddcart").val("notsupport");
                                alert('选择地址信息不在配送范围');
                                return;
                            }
                        } else if (flowerDeliveryType == 0) {
                            $("#canaddcart").val("notsupport");
                            alert('选择地址信息不在配送范围');
                            return;
                        }
                    } else {
                        //错误信息提示
                    }
                },
                error: function () {
                    //alert('加载菜单数据失败!');
                }
            });
        });
    </script>

</body>
</html>
